package rmioverlay.server;

import rmioverlay.*;
import rmioverlay.client.ClientAppInterface;
import rmioverlay.lib.users.*;
import java.rmi.RemoteException;

public interface ServerAppInterface extends AppInterface {
	
	/**
	 * Registers a recently connected client in client list
	 * @param pClient The client to register
	 * @throws RemoteException if a network issue occurs
	 */
	@SuppressWarnings("rawtypes")
	public void addClient(ClientAppInterface pClient)
			throws RemoteException;

	/**
	 * Registers a recently connected client in client list
	 * @param pClient The client to register
	 * @param user the User associated to this ClientApp
	 * @throws RemoteException if a network issue occurs
	 */
	@SuppressWarnings("rawtypes")
	public void addClient(ClientAppInterface pClient, User user)
			throws RemoteException;
	
	/**
	 * Removes a registered client
	 * @param pClient The client to remove
	 * @throws RemoteException if a network issue occurs
	 */
	@SuppressWarnings("rawtypes")
	public void removeClient(ClientAppInterface pClient)
			throws RemoteException;

	/**
	 * Sends a message to all connected clients
	 * @param data the data to send
	 * @throws RemoteException if a network issue occurs
	 */
	public <T>void sendAll(T data)
			throws RemoteException;

	/**
	 * Sends a byte array to all connected clients
	 * @param pData the data to send
	 * @param pFilename the original file name
	 * @throws RemoteException if a network issue occurs
	 */
	public void sendAll(byte[] pData, String pFilename)
			throws RemoteException;
	
	/**
	 * Sends data to a registered client
	 * @param <T> the type of data which will be sent
	 * @param pLogin the login of recipient user
	 * @param data the data to send
	 * @throws RemoteException if a network issue occurs
	 */
	public <T>void send(String pLogin, T data)
			throws RemoteException;
	
	/**
	 * Sends a byte array to a connected client
	 * @param pLogin the login of recipient user
	 * @param pData the data to send
	 * @param pFilename the original file name
	 * @throws RemoteException if a network issue occurs
	 */
	public void send(String pLogin, byte[] pData, String pFilename)
			throws RemoteException;
	
	/**
	 * Logs a user in
	 * @param pClient the ClientApp reference
	 * @param pLogin the typed login
	 * @param pPass the typed password
	 * @return whether user has been logged in successfully or not
	 * @throws RemoteException if a network issue occurs
	 */
	@SuppressWarnings("rawtypes")
	public boolean login(ClientAppInterface pClient, String pLogin, String pPass)
			throws RemoteException;

}